	
// EnumStuderende.h : Declaration of the CEnumStuderende

#ifndef __ENUMSTUDERENDE_H_
#define __ENUMSTUDERENDE_H_

#include "resource.h"       // main symbols
#include "importado.h"
#include "database.h"

/////////////////////////////////////////////////////////////////////////////
// CEnumStuderende
class ATL_NO_VTABLE CEnumStuderende : 
	public CComObjectRootEx<CComMultiThreadModel>,
	public CComCoClass<CEnumStuderende, &CLSID_EnumStuderende>,
	public ISupportErrorInfo,
	public IDispatchImpl<IEnumStuderende, &IID_IEnumStuderende, &LIBID_EBASDLLLib>
{
public:
	CEnumStuderende();
	virtual ~CEnumStuderende();

DECLARE_REGISTRY_RESOURCEID(IDR_ENUMSTUDERENDE)
DECLARE_NOT_AGGREGATABLE(CEnumStuderende)
DECLARE_GET_CONTROLLING_UNKNOWN()

DECLARE_PROTECT_FINAL_CONSTRUCT()

BEGIN_COM_MAP(CEnumStuderende)
	COM_INTERFACE_ENTRY(IEnumStuderende)
	COM_INTERFACE_ENTRY(IDispatch)
	COM_INTERFACE_ENTRY(ISupportErrorInfo)
	COM_INTERFACE_ENTRY_AGGREGATE(IID_IMarshal, m_pUnkMarshaler.p)
END_COM_MAP()

	HRESULT FinalConstruct()
	{
		return CoCreateFreeThreadedMarshaler(
			GetControllingUnknown(), &m_pUnkMarshaler.p);
	}

	void FinalRelease()
	{
		m_pUnkMarshaler.Release();
	}

	CComPtr<IUnknown> m_pUnkMarshaler;

// ISupportsErrorInfo
	STDMETHOD(InterfaceSupportsErrorInfo)(REFIID riid);

// IEnumStuderende
public:
	STDMETHOD(Clone)(/*[out]*/ IEnumeration ** ppEnumeration);
	STDMETHOD(Reset)();
	STDMETHOD(Skip)(/*[in]*/ ULONG cItems);
	STDMETHOD(Next)(/*[out]*/ IUnknown ** ppUnk, /*[out]*/ ULONG * pcFetched);
	STDMETHOD(findStuderende)(BSTR cpr, IStuderende ** ppStud);
	STDMETHOD(put_GruppeMedlemmer)(BSTR navn)
	{
		m_gruppeNavn = navn;

		return S_OK;
	}
private:
	_RecordsetPtr m_records;
	bool m_first;
	ULONG m_pos;
	ULONG m_length;
	bstr_t m_gruppeNavn;
};

#endif //__ENUMSTUDERENDE_H_
